﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Threading;
using TIBCO.EMS;

namespace TibcoMessageAdmin
{

  class CustMsg
    {
      public TextMessage _txtMessage = null ;
      public string MessageID
      {

          get {
              return _txtMessage.MessageID ; 
          }


      }
      public CustMsg(TextMessage msg)
      {

          _txtMessage = msg;
      }



      public override string ToString()
      {
          
          return _txtMessage.MessageID.ToString() + " # " + ut_time(_txtMessage.Timestamp) ;
          
      }

      /// <summary>
      /// method for converting a UNIX timestamp to a regular
      /// System.DateTime value (and also to the current local time)
      /// </summary>
      /// <param name="timestamp">value to be converted</param>
      /// <returns>converted DateTime in string format</returns>
      private static DateTime ConvertTimestamp(double timestamp)
      {
          //create a new DateTime value based on the Unix Epoch
          DateTime converted = new DateTime(1970, 1, 1, 0, 0, 0, 0);

          //add the timestamp to the value
          DateTime newDateTime = converted.AddSeconds(timestamp);

          //return the value in string format
          return newDateTime.ToLocalTime();
      }

 
    private string ut_time(double timestamp)
    {
        DateTime unix_start = DateTime.Parse("01/01/1970");
        DateTime dt =  unix_start.AddMilliseconds(timestamp);
        return dt.ToString("yyyy-MM-dd HH:MM:sss"); 
    }

    }
}
